package com.principles.create.factory;

/**
 * @Description  工厂模式 一个工厂可以生产多个物品
 * @Date 2025/1/26 19:4一
 **/

class Test {
    public static void main(String[] args) {
        Factory factory = new HWPhoneFactory();
        Phone phone = factory.createPhone();
        phone.create();
    }
}

interface Factory {
    Phone createPhone();
}

interface Phone {
    public void create();
}

class IPhone implements Phone {
    @Override
    public void create() {
        System.out.println("苹果手机");
    }
}

class HWPhone implements Phone {
    @Override
    public void create() {
        System.out.println("华为手机");
    }
}

class IPhoneFactory implements Factory {

    @Override
    public Phone createPhone() {
        return new IPhone();
    }
}

class HWPhoneFactory implements Factory {

    @Override
    public Phone createPhone() {
        return new HWPhone();
    }
}